package com.hyzx.qbasic.admin.domain.repository.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hyzx.qbasic.admin.domain.dao.SysDataSetMapper;
import com.hyzx.qbasic.admin.domain.repository.ISysDataSetRepository;
import com.hyzx.qbasic.admin.model.po.SysDataSetPO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 数据集管理 仓储实现类
 *
 * @author 黄江华
 * @since 2019-04-09
 */

@Repository
public class SysDataSetRepositoryImpl implements ISysDataSetRepository {

    @Autowired
    private SysDataSetMapper sysDataSetMapper;

    @Override
    public PageInfo<SysDataSetPO> getPagedSysDataSetList(int pageNum, int pageSize, String datasetName) {
        PageInfo<SysDataSetPO> pageInfo = PageHelper.startPage(pageNum, pageSize)
                .doSelectPageInfo(() -> sysDataSetMapper.getPagedSysDataSetList(datasetName));

        return pageInfo;
    }

    @Override
    public SysDataSetPO getSysDataSetById(Integer datasetId) {
        return sysDataSetMapper.getSysDataSetById(datasetId);
    }

    @Override
    public SysDataSetPO getSysDataSetByName(String datasetName) {
        return sysDataSetMapper.getSysDataSetByName(datasetName);
    }

    @Override
    public boolean addSysDataSet(SysDataSetPO record) {
        return sysDataSetMapper.addSysDataSet(record) > 0;
    }

    @Override
    public boolean editSysDataSet(SysDataSetPO record) {
        return sysDataSetMapper.editSysDataSet(record) > 0;
    }

    @Override
    public boolean deleteSysDataSetByIds(List<Integer> idList) {
        return sysDataSetMapper.deleteSysDataSetByIds(idList) > 0;
    }
}
